package com.gzc.pm.logic
{
	import cn.skyclass.business.SessionManager;
	import cn.skyclass.net.BaseLoader;
	
	import com.gzc.pm.dao.DetectionCardDao;
	import com.gzc.pm.util.MyUtil;
	
	import mx.collections.ArrayCollection;
	import mx.rpc.events.ResultEvent;
	
	public class DetectionCardLoader extends BaseLoader
	{
		
		public function DetectionCardLoader(procId:int, startDate:Date, endDate:Date=null)
		{
			_procId = procId;
			_startDate = startDate;
			_endDate = endDate;
		}
		
		private var _procId:int;//工序ID
		private var _startDate:Date;
		private var _endDate:Date;
		public var detsetbs:ArrayCollection;//某工序中，检测项配置信息
		
		override protected function doLoad():void{
			var procEquData:ProcEquLoader = SessionManager.current.getAttribute('procEquData') as ProcEquLoader;
			detsetbs = procEquData.detsetbDict[_procId];
			
			var sDateStr:String = MyUtil.date2StringWithoutHMS(_startDate, true);
			var eDateStr:String = _endDate ? MyUtil.date2StringWithoutHMS(_endDate, false) : "30001231235959";
			
			var dao:DetectionCardDao = new DetectionCardDao();
			dao.getByPrId(_procId, sDateStr, eDateStr, _onDetectionCardLoaded);
		}
		
		private function _onDetectionCardLoaded(e:ResultEvent):void{
			resultList = e.result as ArrayCollection;//检测项列表
			
			dispatchLoadedEvent();
		}
		
	}
}